<template>
  <div class="refine_intendance">
    <h2 class="titleblue">任务督查</h2>
    <div class="contant">
      <el-row :gutter="20">
        <el-col :span="12">
          <div class="grid-content bg-purple fl">
            <label>开始时间</label>
            <el-date-picker class="select-width-180" value-format='yyyy-MM-dd'
                            v-model="chooption.startTime" align="right"
                            type="date" placeholder="选择日期" :picker-options="pickerOptions1">
            </el-date-picker>
          </div>
          <div class="grid-content bg-purple fl margin-left-10">
            <label>结束时间</label>
            <el-date-picker class="select-width-180" v-model="chooption.endTime" align="right"
                            type="date" placeholder="选择日期"
                            value-format='yyyy-MM-dd' :picker-options="pickerOptions1">
            </el-date-picker>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple fl">
            <label>任务等级</label>
            <el-select clearable class="select-width-180" v-model="chooption.grade" placeholder="请选择">
              <el-option v-for="item in tasklevel" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="grid-content bg-purple fl margin-left-10">
            <label>督察人员</label>
            <el-select clearable v-model="chooption.superviseUserId" placeholder="请选择" class="select-width-150">
              <el-option v-for="item in sysUser" :key="item.id" :label="item.fullname" :value="item.id">
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <label>任务类型</label>
            <el-select clearable class="select-width-220" v-model="chooption.type1"
                       @change="typeChange($event, 'first')"
                       placeholder="请选择">
              <el-option v-for="item in taskType" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-220" v-model="chooption.type2"
                       @change="typeChange($event, 'second')"
                       placeholder="请选择" v-if="tasktype2.length">
              <el-option v-for="item in tasktype2" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-220" v-model="chooption.type3"
                       placeholder="请选择" v-if="tasktype3.length">
              <el-option v-for="item in tasktype3" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12" style="text-align:left;">
          <div class="grid-content bg-purple">
            <label>任务创建</label>
            <el-select clearable class="select-width-150" v-model="create_org" placeholder="请选择"
                       @change="createChange($event)">
              <el-option v-for="(item,index) in organization" :key="index" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable v-if="organizationCreate.length" class="select-width-150"
                       v-model="create_dept" @change="createChange2($event)"
                       placeholder="请选择">
              <el-option v-for="(item,index) in organizationCreate" :key="index"
                         :label="item.name ? item.name : item.fullname"
                         :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable v-if="organizationCreate2.length" class="select-width-150"
                       v-model="chooption.cu_id"
                       placeholder="请选择">
              <el-option v-for="(item,index) in organizationCreate2" :key="index" :label="item.fullname"
                         :value="item.id">
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <label>任务派发</label>
            <el-select clearable class="select-width-200" v-model="chooption.distribute"
                       @change="sendChange($event, 'first')"
                       placeholder="请选择">
              <el-option v-for="item in organization" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-200" v-if="organization2.length"
                       @change="sendChange($event, 'second')"
                       v-model="chooption.enforcement_brigade"
                       placeholder="请选择">
              <el-option v-for="item in organization2" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>

          </div>
        </el-col>
        <el-col :span="12" :xl='12'>
          <div class="grid-content bg-purple">
            <label>执行单元</label>
            <el-select clearable class="select-width-150" v-model="chooption.unit_people"
                       placeholder="请选择">
              <el-option v-for="item in taskperson" :key="item.id" :label="item.fullname" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-150" v-model="chooption.unit_carrier"
                       placeholder="请选择">
              <el-option v-for="item in taskcarrier" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-150" v-model="chooption.unit_car"
                       placeholder="请选择">
              <el-option v-for="item in taskcar" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
            <el-select clearable class="select-width-150" v-model="chooption.unit_tool"
                       placeholder="请选择">
              <el-option v-for="item in tasktool" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12" :xl='12'>
          <div class="grid-content bg-purple">
          </div>
        </el-col>
        <el-col :span="12" style="float:left;">
          <el-input clearable prefix-icon="el-icon-search" placeholder="搜索任务" v-model="chooption.name"
                    class="plansearch">
          </el-input>
          <el-button class="el-button el-button--primary" @click="search(0)">搜索</el-button>
        </el-col>
        <el-col>
          <el-tabs v-model="plantabs" type="card" @tab-click="handleClick">
            <el-tab-pane label="任务待督查列表" name="first">
              <el-table border stripe :data="notintendance_tableData" style="width: 100%">
                <el-table-column label="序号" align="center" width="70" prop="d_id">
                  <template slot-scope="scope">
                    <span v-if='scope.$index!=9'>{{(currentPage1-1).toString()+parseInt(scope.$index+1)}}</span>
                    <span v-else>{{currentPage1+'0'}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskNo" label="任务编号" align="center"></el-table-column>
                <el-table-column prop="name" label="任务名称" align="center"></el-table-column>
                <el-table-column prop="organiza" label="所属辖区" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.organiza ? scope.row.organiza.name : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskTypeFlows" label="任务类型" align="center">
                  <template slot-scope="scope">
                    <span v-for="item in scope.row.taskTypeFlows">{{ttypes(item) ? ttypes(item) : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="grade" label="任务等级" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.grade == 2 ? '一般':'紧急'}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="endTime" label="完成时间" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.finishTime ? $m(scope.row.finishTime).format('YYYY-MM-DD') : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskUsers" label="执行单元" align="center">
                  <template slot-scope="scope">
                    <span v-for="item in scope.row.taskUsers">{{toUser(item.userId)}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="80">
                  <template slot-scope="scope">
                    <el-button size="mini" type="text"
                               @click="showScope({data: scope.row, action: 'view', type: scope.row.superviseFlag})">查看
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="任务已督查列表" name="second">
              <el-table border stripe :data="hasintendance_tableData" style="width: 100%">
                <el-table-column label="序号" align="center" width="70" prop='d_id'>
                  <template slot-scope="scope">
                    <span v-if='scope.$index!=9'>{{(currentPage2-1).toString()+parseInt(scope.$index+1)}}</span>
                    <span v-else>{{currentPage2+'0'}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskNo" label="任务编号" align="center"></el-table-column>
                <el-table-column prop="name" label="任务名称" align="center"></el-table-column>
                <el-table-column prop="organiza" label="所属辖区" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.organiza ? scope.row.organiza.name : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskTypeFlows" label="任务类型" align="center">
                  <template slot-scope="scope">
                    <span v-for="item in scope.row.taskTypeFlows">{{ttypes(item) ? ttypes(item) : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="grade" label="任务等级" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.grade == 2 ? '一般':'紧急'}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="endTime" label="完成时间" align="center">
                  <template slot-scope="scope">
<!--                    <span>{{scope.row.deadline ? $m(scope.row.deadline).format('YYYY-MM-DD') : ''}}</span>-->
                    <span>{{scope.row.finishTime ? $m(scope.row.finishTime).format('YYYY-MM-DD HH:mm:ss') : ''}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="taskUsers" label="执行单元" align="center">
                  <template slot-scope="scope">
                    <span v-for="item in scope.row.taskUsers">{{toUser(item.userId)}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="superviseUserName" label="督察人员" align="center"></el-table-column>
                <el-table-column prop="superviseResult" show-overflow-tooltip label="督查意见"
                                 align="center"></el-table-column>
                <el-table-column label="操作" align="center" width="80">
                  <template slot-scope="scope">
                    <el-button size="mini" type="text"
                               @click="showScope({data: scope.row, action: 'view', type: scope.row.superviseFlag})">查看
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </el-col>
        <el-col>
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                         :current-page.sync="currentPage1"
                         layout="total,prev, pager, next, jumper" :total="total1" background v-if="plantabs=='first'">
          </el-pagination>

          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                         :current-page.sync="currentPage2"
                         layout="total,prev, pager, next, jumper" :total="total2" background v-if="plantabs=='second'">
          </el-pagination>
        </el-col>
      </el-row>
    </div>

    <!--  任务都察  -->
    <router-view @close='close'></router-view>

  </div>
</template>

<script>
  import DataTable from '@/components/common/DataTable.vue'
  import TaskDetail from '@/components/Task/TaskSearch/TaskDetail.vue'
  import taskService from '@/services/TaskService.js'
  import taskTypeService from '@/services/TaskTypeService'
  import plansService from '@/services/PlansService'
  import moment from 'moment'
  import taskObjectService from '@/services/TaskObjectService'
  import * as organizationService from '@/services/OrganizationService'
  import * as sysUserService from '@/services/SysUserService'

  export default {
    components: {
      'data-table': DataTable,
      'task-detail': TaskDetail
    },
    data: function () {
      return {
        chooption: {
          startTime: '',
          endTime: '',
          grade: '',
          enforcement_brigade: '',
          superviseUserId: '',
          distribute: '',
          taskState: '',
          type1: '',
          type2: '',
          type3: '',
          unit_people: '',
          unit_carrier: '',
          unit_car: '',
          unit_tool: '',
          inspectionOrNot: '',
          name: '',
          evaluate: '',
          special: '',
          cu_org: '',
          cu_id: '',
        },
        plantabs: 'first',
        currentPage1: 1,
        currentPage2: 1,
        type_first: [],
        type_second: [],
        taskO: [],
        create_first: [],
        create_second: [],
        create_third: [],

        create_org: '',
        create_dept: '',
        tasklevel: [{
          label: '一般',
          value: 1
        }, {
          label: '紧急',
          value: 2
        }],
        taskstatus: [],
        taskperson: [],
        taskcarrier: [],
        taskcar: [],
        tasktool: [],
        tasktype: [],
        tasktype1: [],
        tasktype2: [],
        intendanceArr: [],
        pickerOptions1: {
          // disabledDate(time) {
          //   return time.getTime() > Date.now();
          // },
          shortcuts: [{
            text: '今天',
            onClick (picker) {
              picker.$emit('pick', new Date())
            }
          }, {
            text: '昨天',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24)
              picker.$emit('pick', date)
            }
          }, {
            text: '一周前',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', date)
            }
          }]
        },
        notintendance_tableData: [],//待督查
        total1: 1,
        hasintendance_tableData: [],//已督查
        total2: 1,
        member: '',
        successDialog: false,
        dialogWidth: '80%',
        taskType: [],
        organization: [],
        sysUser: [],
        plans: [],
        tasktype3: [],
        organization2: [],
        organizationCreate: [],
        organizationCreate2: [],
        detailType: ''
      }
    },
    created () {
      this.getSelect()
      this.search(0)
    },
    methods: {
      toUser (id) {
        let obj
        if (id) {
          obj = this.sysUser.find(item => {
            return item.id == id
          })
        }
        if (obj) {
          return obj.fullname
        }
      },
      ttypes(item) {
        let task = ''
        let obj1 = {}, obj2 = {}, obj3 = {}
        if (item.type1) {
          for (let task of this.taskType) {
            if (task.id == item.type1) obj1 = task
          }
          task = obj1.name
          if (obj1 && obj1.subset) {
            for (let task of obj1.subset) {
              if (task.id == item.type2) obj2 = task
            }
            if (item.type2) task = obj2.name
            if (obj2 && obj2.subset && item.type2) {
              for (let task of obj2.subset) {
                if (task.id == item.type3) obj3 = task
              }
              if (obj3 && item.type3) {
                task = obj3.name
              }
            }
          }
        }
        return task
      },
      // 处理拼接query
      handlerQuery () {
        let str = ''
        if (this.chooption.startTime) {
          str += 'begineTime.greaterOrEqualThan=' + moment(this.chooption.startTime).toISOString()
        }
        if (this.chooption.endTime) {
          if (str) {
            str += '&'
          }
          str += 'endTime.lessOrEqualThan=' + moment(this.chooption.endTime).toISOString()
        }
        if (this.chooption.grade) {
          if (str) {
            str += '&'
          }
          str += 'grade.equals=' + this.chooption.grade
        }
        if (this.chooption.type1) {
          if (str) {
            str += '&'
          }
          str += 'taskTypeFlowId1.equals=' + this.chooption.type1
        }
        if (this.chooption.type2) {
          if (str) {
              str += '&'
          }
          str += 'taskTypeFlowId2.equals=' + this.chooption.type2
        }
        if (this.chooption.type3) {
          if (str) {
              str += '&'
          }
          str += 'taskTypeFlowId3.equals=' + this.chooption.type3
        }
          if (this.chooption.enforcement_brigade) {
              if (str) {
                  str += '&'
              }
              let orgObj2 = this.organization2.find(async item => {
                  return item.id == this.chooption.enforcement_brigade
              })
              console.log(orgObj2)
              if (orgObj2.businessOrg == 5) { // 指挥中心
                  str += 'centerTaskFlag.equals=true'
              } else if (orgObj2.businessOrg == 1 || orgObj2.businessOrg == 2) { // 业务部门 || 行政部门
                  str += 'businessUnit.equals=' + this.chooption.enforcement_brigade
              } else if (orgObj2.businessOrg == 3) { // 海事处
                  str += 'managementUnit.equals=' + this.chooption.enforcement_brigade
              } else if (orgObj2.businessOrg == 4) { // 执法大队
                  str += 'enforcementBrigade.equals=' + this.chooption.enforcement_brigade
              } else if (orgObj2.businessOrg == 0) { // 局领导
                  // str = str.substring(0, str.length - 1)
                  str += 'enforcementBrigade.equals=' + -1
              }
              // str += 'enforcementBrigade.equals=' + this.chooption.distribute
          } else if (this.chooption.distribute) {
              if (str) {
                  str += '&'
              }
              let orgObj = this.organization.find(item => {
                  return item.id == this.chooption.distribute
              })
              console.log(orgObj)
              if (orgObj.businessOrg == 5) { // 指挥中心
                  str += 'centerTaskFlag.equals=true'
              } else if (orgObj.businessOrg == 1 || orgObj.businessOrg == 2) { // 业务部门 || 行政部门
                  str += 'businessUnit.equals=' + this.chooption.distribute
              } else if (orgObj.businessOrg == 3) { // 海事处
                  str += 'managementUnit.equals=' + this.chooption.distribute
              } else if (orgObj.businessOrg == 4) { // 执法大队
                  str += 'enforcementBrigade.equals=' + this.chooption.distribute
              } else if (orgObj.businessOrg == 0) { // 局领导
                  // str = str.substring(0, str.length - 1)
                  str += 'enforcementBrigade.equals=' + -1
              }
              // str += 'managementUnit.equals=' + this.chooption.distribute
          }
        if (this.chooption.superviseUserId) {
          if (str) {
            str += '&'
          }
          str += 'superviseUserId.equals=' + this.chooption.superviseUserId
        }
        if (this.create_org) {
          if (str) {
            str += '&'
          }
          str += 'createUserId.equals=' + (this.chooption.cu_id ? this.chooption.cu_id : (this.create_dept ? this.create_dept : this.create_org))
        }
        if (this.chooption.name) {
          if (str) {
            str += '&'
          }
            if (isNaN(this.chooption.name.trim())){
                str += 'name.contains=' + this.chooption.name
            } else {
                str += 'taskNo.contains=' + this.chooption.name
            }
        }
        return str
      },
      search (num = 0) {
        if (num == 0) {
          this.$set(this, 'currentPage1', 1)
          this.$set(this, 'currentPage2', 1)
        }
        let str = this.handlerQuery()
        if (this.plantabs == 'first') {
          str += (str ? '&' : '') + 'superviseFlag.equals=false'
          taskService.criteriaQueries(num, str, 10).then(res => {
            this.notintendance_tableData = res.data
            this.total1 = parseInt(res.headers['x-total-count'], 10)
          })
        } else if (this.plantabs == 'second') {
          str += (str ? '&' : '') + 'superviseFlag.equals=true'
          taskService.criteriaQueries(num, str, 10).then(res => {
            this.hasintendance_tableData = res.data
            this.total2 = parseInt(res.headers['x-total-count'], 10)
          })
        }
        // taskService.criteriaQueries(0, str, 10).then(res => {
        //
        //   this.tableData1 = res.data
        //   this.total = res.data.length
        // })
      },
      async createChange (val) {
        this.organizationCreate = []
        this.organizationCreate2 = []
        this.create_dept = ''
        this.chooption.cu_id = ''
        let type = await this.organization.find(item => {
          return item.id == val
        })
        if (type && type.sub) {
          this.$set(this, 'organizationCreate', type.sub)
        } else {
          let arr = await this.sysUser.filter(fil => {
            if (fil.organiza) {
              return fil.organiza.id == val
            }
          })
          arr.sort((a, b) => {
              if (a.level < b.level) {
                  return 1
              } else {
                  return -1
              }
              return 0
          })
          this.$set(this, 'organizationCreate', arr)
        }
      },
      async createChange2 (val) {
        //
        this.organizationCreate2 = []
        this.chooption.cu_id = ''
        let arr = await this.sysUser.filter(fil => {
          if (fil.organiza) {
            return fil.organiza.id == val
          }
        })
        if (arr) {
          arr.sort((a, b) => {
              if (a.level < b.level) {
                  return 1
              } else {
                  return -1
              }
              return 0
          })
          this.$set(this, 'organizationCreate2', arr)
        }
      },
      async sendChange (val, kind) {
        if (kind == 'first') {
          this.organization2 = []
          this.chooption.enforcement_brigade = ''
          let type = this.organization.find(item => {
            return item.id == val
          })
          if (type && type.sub) {
            this.$set(this, 'organization2', type.sub)
          }
        }
        this.chooption.unit_people = ''
        let arr = await this.sysUser.filter(fil => {
          if (fil.organiza) {
            return fil.organiza.id == val
          }
        })
        if (arr) {
          arr.sort((a, b) => {
              if (a.level < b.level) {
                  return 1
              } else {
                  return -1
              }
              return 0
          })
          this.$set(this, 'taskperson', arr)
        }
      },
      typeChange (val, kind) {
        if (kind == 'first') {
          this.chooption.type2 = ''
          this.chooption.type3 = ''
          this.tasktype2 = []
          this.tasktype3 = []
          let type = this.taskType.find(item => {
            return item.id == val
          })
          if (type && type.subset) {
            this.tasktype2 = type.subset
          }
        } else if (kind == 'second') {
          this.chooption.type3 = ''
          this.tasktype3 = []
          let type = this.tasktype2.find(item => {
            return item.id == val
          })
          if (type && type.subset) {
            this.tasktype3 = type.subset
          }
        }
      },
      getSelect () {
        taskTypeService.search().then(res => {

          this.taskType = res
        })
        organizationService.findAll().then(async res => {
          await res.data.sort((a, b) => {
            if (a.businessOrg < b.businessOrg) {
              return -1
            }
            if (a.businessOrg > b.businessOrg) {
              return 1
            }
            return 0
          })
          this.organization = res.data
          // this.organizaAll = res.dataAll
        })
        sysUserService.findAll().then(res => {
          this.sysUser = res.data
        })
        plansService.searchAll().then(res => {
          this.plans = res
        })
        taskObjectService.search().then(res => {
          this.taskObjectType = res
        })
      },
      getData (num) {
        let str = ''
        if (this.plantabs == 'first') {
          str = 'superviseFlag==false'
          // let str = this.handlerQuery()
          taskService.ps(num, str).then(res => {
            this.notintendance_tableData = res.data
            this.total1 = res.dataCount
          })
        } else if (this.plantabs == 'second') {
          str = 'superviseFlag==true'
          // let str = this.handlerQuery()
          taskService.ps(num, str).then(res => {
            this.hasintendance_tableData = res.data
            this.total2 = res.dataCount
          })
        }
      },
      handleClick () {
        this.search()
      },
      changeType () {
        this.tasktype2 = []
        this.chooption.tasktype2 = ''
        for (var i of this.tasktype) {
          if (i.d_id == this.chooption.type_first) {
            for (var j of i.son) {
              this.tasktype2.push({
                label: j.name,
                value: j.d_id
              })
            }

          }
        }
        this.getData('1', 1)
      },
      changeOrg (val) {
        this.taskperson = []
        this.taskcarrier = []
        this.taskcar = []
        this.tasktool = []
        this.type_second = []
        this.chooption.unit_people = ''
        this.chooption.unit_carrier = ''
        this.chooption.unit_car = ''
        this.chooption.unit_tool = ''
        this.chooption.enforcement_brigade = ''
        for (var i of this.taskO) {
          if (i.d_id == val) {
            for (var j of i.son) {
              this.type_second.push({
                label: j.name,
                value: j.d_id
              })
            }

          }
        }
        this.getData('1', 1)
      },
      changeDept (val) {
        this.taskperson = []
        this.taskcarrier = []
        this.taskcar = []
        this.tasktool = []
        this.chooption.unit_people = ''
        this.chooption.unit_carrier = ''
        this.chooption.unit_car = ''
        this.chooption.unit_tool = ''
        if (val) {
          this.$axios.get(this.$config['disUser'], {
            params: {
              skey: localStorage.getItem('auth'),
              dId: val
            }
          }).then((res) => {
            this.taskperson = res.data.content
          })
          this.$axios.get(this.$config['searchLawUnit'], {
            params: {
              skey: localStorage.getItem('auth'),
              orgId: val
            }
          }).then((res) => {

            var data = res.data.content

            this.taskcarrier = data.ships
            this.taskcar = data.cars
            this.tasktool = data.tools
          })

        }
        this.getData('1', 1)
      },
      // getData (id, val) {
      //
      //   if (this.plantabs.lastIndexOf('first') == -1) {
      //     this.getIngData(val)
      //   } else {
      //     this.getUnData(val)
      //   }
      // },
      getIngData (val) {
        this.chooption.page = val || 1
        this.chooption.counts = 10
        this.chooption.skey = localStorage.getItem('auth')
        this.$axios.get(this.$config['taskinpec'], {params: this.chooption}).then((res) => {
          this.total2 = res.data.content.shipSize

          for (var j of res.data.content.ships) {

            for (var i of this.taskperson) {
              if (i.value == j.unit_people) {
                j.unit_people = i.label
              }
            }
            for (var i of this.tasklevel) {
              if (i.value == j.grade) {
                j.grade = i.label
              }
            }
            for (var i of this.tasktype) {
              if (i.d_id == j.type_first) {
                j.type_first = i.name
                break
              } else {
                for (var k of i.son) {

                  if (k.d_id == j.type_first) {
                    j.type_first = k.name
                    break
                  }
                }
              }
            }
          }
          this.hasintendance_tableData = res.data.content.ships
        })
      },
      getUnData (val) {
        this.chooption.page = val || 1
        this.chooption.counts = 10
        this.chooption.skey = localStorage.getItem('auth')
        this.$axios.get(this.$config['taskuninspec'], {params: this.chooption}).then((res) => {
          this.total1 = res.data.content.shipSize
          for (var j of res.data.content.ships) {
            for (var i of this.taskperson) {
              if (i.value == j.unit_people) {
                j.unit_people = i.label
              }
            }
            for (var i of this.tasklevel) {
              if (i.value == j.grade) {
                j.grade = i.label
              }
            }
            for (var i of this.tasktype) {
              if (i.d_id == j.type_first) {
                j.type_first = i.name
                break
              } else {
                for (var k of i.son) {
                  if (k.d_id == j.type_first) {
                    j.type_first = k.name
                    break
                  }
                }
              }
            }
          }
          this.notintendance_tableData = res.data.content.ships
        })
      },
      manipulate (s, id) {
        var doing = s.split('-')
        if (doing[0] == 'edit') {
          this.adddialog = true
          this.$router.push('/index/tele/inwan/imedit')
          this.member = this.tableData1[doing[1]]
        }
        if (doing[0] == 'look') {
          this.adddialog = true
          this.$router.push('/index/tele/inwan/imdetail')
          this.member = this.tableData1[doing[1]]
        }
      },
      //列表查看
      showScope (param) {
        // this.member = row.d_id
        this.successDialog = true
        // this.taskDetail = param.data
        // this.detailType = param.type
        this.$router.push({name: 'supDetail', params: {data: param.data, pageType: 'supervision', detailType: param.type}})
      },
      handleSizeChange (val) {
        this.search(val - 1)
      },
      handleCurrentChange (val) {
        this.search(val - 1)
      },
      changeWidth (res) {
        this.dialogWidth = res
      },
      close () {
        this.successDialog = false
        this.$router.push("/task-supervision")
        this.search()
      },
      createOrg (val) {
        this.create_dept = ''
        this.chooption.cu_id = ''
        this.create_third = []
        this.create_second = []
        for (var i of this.taskO) {
          if (i.d_id == this.create_org) {
            for (var x of i.son) {
              this.create_second.push({
                label: x.name,
                value: x.d_id
              })
            }

          }
        }
        if (val) {
          this.$axios.get(this.$config['disUser'], {
            params: {
              skey: localStorage.getItem('auth'),
              dId: val
            }
          }).then((res) => {
            this.create_third = res.data.content
          })
        }
        this.chooption.cu_org = this.create_org
        this.getData('1', 1)
      },
      createDept (val) {
        this.chooption.cu_id = ''
        this.create_third = []
        if (val) {
          this.$axios.get(this.$config['disUser'], {
            params: {
              skey: localStorage.getItem('auth'),
              dId: val
            }
          }).then((res) => {
            this.create_third = res.data.content
          })
        }
        this.chooption.cu_org = this.create_dept
        this.getData('1', 1)

      },
      createPerson () {
        this.search('1', 1)
      },

    }
  }
</script>

<style lang="scss">
  .refine_intendance {
    .contant {
      padding-bottom: 20px;

      .select-width-100 {
        width: 125px;
      }

      .select-width-150 {
        width: 154px;
      }

      .el-col {
        padding: 10px 0px;
        padding-left: 0px !important;
        padding-right: 0px !important;

        .grid-content label {
          line-height: 40px;
        }

        .margin-left-10 {
          margin-left: 10px;
        }

        .select-width-180 {
          width: 200px;
        }

        .select-width-220 {
          width: 233px;
        }

        .select-width-200 {
          width: 200px;
        }

        .plansearch {
          float: left;
          width: 218px;

        }

        .plansearch input {
          width: 213px;
          margin-right: 10px;
          border-radius: 0;
          float: left;
        }

        .plansearch .el-input-group__append {
          border-left: 1px;
          width: 56px;
          background-color: #0062cd;
          border-radius: 2px;
          font-size: 14px;
          color: #ffffff;
          box-sizing: border-box;
          float: left;
          padding: 0px;
          line-height: 40px;
          height: 40px;
          text-align: center;
        }

        // tab切换样式
        .is-active {
          background-color: #0bb2ff;
          border: solid 1px #0bb2ff;
          font-size: 14px;
          color: #ffffff;
          position: relative;
        }

        .is-active:after {
          content: '';
          display: block;
          width: 0;
          height: 0;
          border-width: 6px 5px 0;
          border-style: solid;
          border-color: #0bb2ff transparent transparent;
          position: absolute;
          top: 39px;
          left: 27px;
          z-index: 99;
        }

        .el-tabs__nav {
          text-align: center;
          padding: 0;
        }

        .el-tabs__item {
          width: 160px;
          border: solid 1px #eeeeee;
          border-left: 1px solid #eee !important;
          border-bottom-color: transparent !important;
        }

        .el-tabs__nav-scroll {
          overflow: visible;
          width: 100%;
          display: inline-block;
        }

        .el-tabs__nav-wrap {
          overflow: visible;
          height: 40px;
        }

        .el-tabs--card > .el-tabs__header {
          border-bottom: 0px;
          margin: 0;
        }
      }

      .intendance-table {
        margin-top: 20px;
      }

      .el-pagination {
        margin-top: 40px;
        text-align: center;
      }
    }
  }

  @media screen and (max-width: 1919px) {
    .refine_intendance {
      .select-width-100 {
        width: 125px !important;
      }

      .select-width-150 {
        width: 113px !important;
      }

      .select-width-200 {
        width: 170px !important;
      }

      .select-width-180 {
        width: 140px !important;
      }

      .select-width-220 {
        width: 170px !important;
      }
    }
  }
</style>
